package com.zhentao.service.impl;

import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.dao.GoodInfoMapper;
import com.zhentao.entity.user.GoodsInfo;
import com.zhentao.service.GoodSearchService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodSearchServiceImpl extends ServiceImpl<GoodInfoMapper, GoodsInfo> implements GoodSearchService {
    @Override
    public List<GoodsInfo> goodSearch(String categoryName) {
        // 非空校验
        if (StringUtils.isBlank(categoryName)) {
            throw new IllegalArgumentException("名称不能为空");
        }

        // 查询条件
//        LambdaQueryWrapper<Good> queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.like(Good::getCategoryName, categoryName);
        QueryWrapper<GoodsInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("goods_name", categoryName);
        return this.baseMapper.selectList(queryWrapper); // 使用 GoodsInfoMapper
    }
}
